package com.ruicar.afs.cloud.afscase.apply.controller;

import com.ruicar.afs.cloud.afscase.mq.approvesendinfo.service.ApproveAttachmentService;
import com.ruicar.afs.cloud.common.core.util.IResponse;
import com.ruicar.afs.cloud.image.condition.ComAttachmentRuleCondition;
import com.ruicar.afs.cloud.image.entity.ComAttachmentManagement;
import com.ruicar.afs.cloud.image.enums.SynchronizationStateEnum;
import com.ruicar.afs.cloud.image.service.ComAttaManageService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Description:
 * @Author: fangchenliang
 * @Date: 2020/8/5 0:42
 */
@RestController
@Slf4j
@AllArgsConstructor
@RequestMapping("/image")
@Api("影像件管理")
public class ImageManageController {
    private ComAttaManageService comAttaManageService;
    private ApproveAttachmentService service;

    @RequestMapping(value = "/dataUpdateAttachment", method = RequestMethod.POST)
    @ApiOperation(value = "附件新增数据同步")
    public IResponse<ComAttachmentManagement> dataUpdateAttachment(@RequestBody ComAttachmentRuleCondition condition) {
        ComAttachmentManagement attachmentManagement = comAttaManageService.getById(condition.getId());
        attachmentManagement.setSynchronizationState(SynchronizationStateEnum.SEND.getCode());
        comAttaManageService.saveOrUpdate(attachmentManagement);
        service.submitAttachmentInfo(attachmentManagement);
        return new IResponse().setData(true);
    }
}
